import sqlite3

#1.connect to database
db_file='./student_test_database.db'
conn=sqlite3.connect(db_file)
print("connect to database successfully");

#2.create cursor
cursor=conn.cursor()
#3.create table
# sql_create_table='CREATE TABLE STUDENT (id INTEGER PRIMARY KEY AUTOINCREMENT,NAME VARCHAR(30),AGE INTEGER)'
# cursor.execute(sql_create_table)
#4.insert data
# sql_insert_one="INSERT INTO STUDENT (NAME,AGE) VALUES(\'Jack\',20)"
# cursor.execute(sql_insert_one)
# sql_insert_data="INSERT INTO STUDENT (NAME,AGE) VALUES(?,?)"
# cursor.execute(sql_insert_data,('ph',10))
#5.update data
#cursor.execute("UPDATE STUDENT SET name=? WHERE id=?",("Jack's brother",3))
#6.delete data
# cursor.execute("DELETE FROM STUDENT WHERE id=?",(3,))
#7.search data

# sql_find_id="SELECT * FROM STUDENT WHERE id=?"
# values=cursor.execute(sql_find_id,(4,))
# for i in values:
#     print('id',i[0])
#     print('name',i[1])
#     print('age',i[2])
# #8.delete table
# cursor.execute("drop table student")
# #commit changes
conn.commit()
#close cursor
cursor.close()
#close connection
conn.close()